package com.antt.cn.test01.ui.activity;

import android.content.Intent;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.antt.cn.test01.R;
import com.antt.cn.test01.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by baichuan on 2017/4/13.
 */

public class IndexActivity extends BaseActivity implements AdapterView.OnItemClickListener {
    private ListView mListView;
    private Toolbar mToolbar;
    private ArrayAdapter<String> adapter;

    private List<Class<? extends BaseActivity>> clt;
    private List<String> slt;


    @Override
    public int getLayoutId() {
        clt = new ArrayList<>();
        slt = new ArrayList<>();
        return R.layout.ac_index;
    }

    @Override
    public void initView() {
        adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, slt);
        mListView = (ListView) findViewById(R.id.ac_index_listView);
        mListView.setAdapter(adapter);

        mToolbar= (Toolbar) findViewById(R.id.ac_index_toolbar);
        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    @Override
    public void initData() {
        getData();
    }

    public void getData() {
        clt.add(MainActivity.class);
        slt.add("MainActivity");


        adapter.notifyDataSetChanged();
    }

    @Override
    public void initListener() {
        mListView.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        startActivity(new Intent(this, clt.get(position)));
    }

}
